Skip to content

test(graphs): cover failure and empty-result behavior of FloydWarshall (R50-T048) - #96

Open
aniruddha-bongale wants to merge 1 commit into
S-AI-Projects:masterfrom
aniruddha-bongale:student/e26b07f0827/R50-T048
Open

aniruddha-bongale wants to merge 1 commit into
S-AI-Projects:masterfrom
aniruddha-bongale:student/e26b07f0827/R50-T048

Conversation

@aniruddha-bongale

Copy link
Copy Markdown

Description

Add comprehensive failure-path and empty-result coverage for FloydWarshall in Graphs/FloydWarshall.js, including unit tests in Graphs/test/FloydWarshall.test.js exercising the smallest valid input ([[0]]), the empty-result path ([]), disconnected component absent-path sentinels (Infinity), ordinary connected graphs, and sequential caller-state resilience. Automated verification is implemented in work/R50-T048/check.py saving execution results to work/R50-T048/results.json.

Related Issue

Fixes: #48

Type of Change

  • Documentation update
  • Tests (adding missing tests or fixing existing tests)

Changes Made

  • Added detailed JSDoc documentation to FloydWarshall in Graphs/FloydWarshall.js explaining the preconditions and execution branches:
    • Line 24: Precondition n = dist.length = 0 bypassing loop entry at Line 25 to execute early exit Line 35 (return dist), yielding the valid empty result [].
    • Line 28: Condition dist[i][j] > dist[i][k] + dist[k][j] evaluates false for disconnected vertices, preserving the Infinity sentinel representing absent shortest paths.
    • Explains in-place matrix mutation behavior and caller preservation.
  • Created Graphs/test/FloydWarshall.test.js covering:
    • Smallest valid input ([[0]]).
    • Empty-result path ([]).
    • Absent-path sentinel (Infinity) for disconnected components.
    • Ordinary 4-vertex connected graph and directed 5-vertex weighted graph.
    • Caller-owned sequential call validity (calling empty path followed immediately by ordinary call).
  • Implemented work/R50-T048/check.py to run native tests, verify assertions on all fixtures with explicit precondition line references, and output work/R50-T048/results.json.

Screenshots / Recordings

All 6 tests in Graphs/test/FloydWarshall.test.js passed cleanly. All repository test suites pass.

Testing

  • Ran npm test -- Graphs/test/FloydWarshall.test.js - all 6 tests passed.
  • Executed python3 work/R50-T048/check.py - all 6 assertions passed and verified.
  • Confirmed Prettier code style check passes.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

Student: Aniruddha Bongale (Enrollment: E26B07F0827)
Task ID: R50-T048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aniruddha Bongale — R50-T048: Cover the failure behavior of FloydWarshall (FloydWarshall.js) [Graphs/FloydWarshall.js]

1 participant